package org.gy.T10.t4;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class ThreadPoolTest3 {
    public static void main(String[] args) throws Exception {
// 1、通过Executors创建⼀个线程池对象。
        ExecutorService pool = Executors.newFixedThreadPool(17);
// ⽼师：核⼼线程数量到底配置多少呢？？？
// 计算密集型的任务：核⼼线程数量 = CPU的核数 + 1
// IO密集型的任务：核⼼线程数量 = CPU核数 * 2
// 2、使⽤线程处理Callable任务。
        Future<String> f1 = pool.submit(new MyCallable(100));
        Future<String> f2 = pool.submit(new MyCallable(200));
        Future<String> f3 = pool.submit(new MyCallable(300));
        Future<String> f4 = pool.submit(new MyCallable(400));
        System.out.println(f1.get());
        System.out.println(f2.get());
        System.out.println(f3.get());
        System.out.println(f4.get());
    }
}
